package routers

import (
	"github.com/gin-gonic/gin"
	"study_abroad_system_back_end/controller"
	"study_abroad_system_back_end/middlewares"
)

func SetupRouter() *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.Cors())
	r.GET("/totalVisits", controller.TotalVisits)
	r.Use(middlewares.Counter())
	r.POST("/register", controller.Register)
	r.POST("/login", controller.Login)
	r.POST("/schoolList",controller.CollegeList)
	r.GET("/schoolDetail/:id",controller.CollegeDetail)
	r.GET("/schoolRank/:id",controller.CollegeRank)
	r.GET("/majorList", controller.MajorList)
	r.GET("/userInfo/:id", controller.QueryInfo)
	r.GET("/collegeRecommend/:id",controller.CollegeRecommend)
	// 需要登录保护的
	authed := r.Group("/")
	authed.Use(middlewares.TokenMiddleWare())
	{
		authed.PUT("/updateInfo/:id",controller.UpdateInfo)
	}

	return r
}


